package com.richdown.myFetion.util;

import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.impl.client.DefaultHttpClient;

public class fetionUtil {
	
	/**
	 * 携带 cookie 向服务端发送请求，并返回结果
	 * @param uri
	 * @param data
	 * @return String
	 */
	public static String postWithCookie(String uri,String data){
		
		DefaultHttpClient httpclient = new DefaultHttpClient();

        // 创建一个本地上下文信息
        HttpContext localContext = new BasicHttpContext();
        // 在本地上下问中绑定一个本地存储
        localContext.setAttribute(ClientContext.COOKIE_STORE, cs);

        // 目标地址
        HttpPost httppost = new HttpPost(
                "http://localhost:8080/app/login");

        System.out.println("请求: " + httppost.getRequestLine());
        // 构造最简单的字符串数据
        StringEntity reqEntity = new StringEntity(
                "username=admin&password=admin");
        // 设置类型
        reqEntity.setContentType("application/x-www-form-urlencoded");
        // 设置请求的数据
        httppost.setEntity(reqEntity);
        // 执行
        HttpResponse response = httpclient.execute(httppost);

        Header[] headers = response.getAllHeaders();
		
		return "";
	}
	
	/**
	 * 通过手机号 获取 uid
	 * @param mobileNo
	 * @return String
	 */
	public static String getUidByMobile(String mobileNo){
		
		
		
		return "";
	}

	/**
	 * 通过 uid 获取 CsrfToken 字段，给好友发飞信时需要这个字段
	 * @param uid
	 * @return String
	 */
	public static String getCsrfToken(String uid){
	
	
	
	return "";
	}


}
